package net.cathackers.devel.scmp.chat.impl.xmpp.messageComponent;

import org.dom4j.Document;
import org.dom4j.Element;

import net.cathackers.devel.scmp.chat.interfaces.ChatConfiguration;
import net.cathackers.devel.scmp.factories.SCMPFactory;
import net.cathackers.devel.scmp.xmpp.Packet;

public class OfflineMessage extends Packet {
    private Element delayElement_;

    public OfflineMessage(Document doc, String delay) {
	super(doc);
	this.setDelay(delay);

    }

    public void setDelay(String delay) {

	delayElement_ = rootElement_.element("delay");
	if (delayElement_ == null) {
	    delayElement_ = rootElement_.addElement("delay");
	    delayElement_.addAttribute("xmlns", "urn:xmpp:delay");
	    ChatConfiguration config = SCMPFactory.getConfiguration();
	    delayElement_.addAttribute("from", config.getChatServerDomain());
	    delayElement_.addAttribute("stamp", delay);

	} else {
	    delayElement_.addAttribute("stamp", delay);
	}
    }
    public String getDelay() {
	return delayElement_.attributeValue("stamp");
	
    }

}
